var btn = document.getElementById("btn");
var container = document.querySelector(".container");


function render( res ){
    res = JSON.parse(res);
    console.log("res");
    container.innerHTML = res.list.map( item => `
    
    <div class="goods">
          <a href="../../src/detail page.html">
                <img src="${ item.small_img }" alt="">
                <h1>${ item.title }</h1>
                <h2>${ item.type } <h2>
                <h3>${ item.price }</h3>
          </a>
    </div>
    `
    ).join("");
}     

window.onload = function(){
    ajax({
        url :"../../static/libs/data/list.json",
        data :{ current :5,pagesize :20},
        callback : render
    })

}


var bullets = document.querySelectorAll("#pagination li");
for(var i = 1 ; i < bullets.length ; i ++){
      bullets[i].onclick = function(){
            
            ajax({
                  url : "http://127.0.0.1:8888/goods/list",
                  data : { current : this.innerHTML , pagesize : 20},
                  callback : render
            })
      }
}






